package io.renren.modules.product.controller;

import io.renren.common.utils.R;
import io.renren.modules.product.entity.ProductUserEntity;
import io.renren.modules.product.service.ProductUserService;
import io.renren.modules.product.vo.TransferVo;
import io.renren.modules.sys.service.SysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhaoyu
 * @since 2023-07-29
 */
@RestController
@RequestMapping("/product-user")
@Api(tags = "产品的团队管理")
public class ProductUserController {
    @Autowired
    ProductUserService productUserService;
    /**
     * 获取开发成员列表和该产品的成员列表
     * @return
     */
    @GetMapping("/transfer")
    @ApiOperation("获取穿梭框数据(产品下成员列表渲染)")
    @RequiresPermissions("product:transfer")
    @ApiImplicitParam(value = "鉴权token",name = "token",paramType = "header", dataType = "String", required=true)
    public R transfer(Long productId){
        Map<String,Object> transfer = productUserService.getTransfer(productId);
        return R.ok().put("transfer",transfer);
    }

    @GetMapping("/saveProductUser")
    @ApiOperation("更新成员列表信息")
    @RequiresPermissions("product:updateProductUser")
    @ApiImplicitParam(value = "鉴权token",name = "token",paramType = "header", dataType = "String", required=true)
    public R updateProductUser(Long productId,Long[] userIds){
        productUserService.updateProductUser(productId,userIds);
        return R.ok("产品团队成员更新成功");
    }



}
